//Accepted
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <iostream>
#include <list>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

bool M[1000][1000], no; // adjacency matrix
int colour[1000]; 		// 0 is white, 1 is gray and 2 is black
int dfsNum[1000]; 		// DFS numbers
int n; 					// the number of vertices
int num;

// returns the smallest DFS number that has a back edge pointing to it
// in the DFS subtree rooted at u
int dfs( int u, int p ) {
	if(!no) return 0;
	colour[u] = 1;
	dfsNum[u] = num++;
	int leastAncestor = num;
	for( int v = 0; v < n && no; v++ ) if( M[u][v] && v != p ) {
		if( colour[v] == 0 ) {
			// (u,v) is a forward edge
			int rec = dfs( v, u );
			if( rec > dfsNum[u] ){
				//cout << "Bridge: " << u+1 << " " << v+1 << endl;
				no=0;
			}
			leastAncestor = min( leastAncestor, rec );
		}
		else {
			// (u,v) is a back edge
			leastAncestor = min( leastAncestor, dfsNum[v] );
		}
	}
	colour[u] = 2;
	return leastAncestor;
}

int main(){
	// ... fill up M[][] with an adjacency matrix
	// ... set n to be the number of vertices
	//freopen("in.txt", "r", stdin);//freopen("out.txt", "w", stdout);
	int  m, i, j, x, y;
	
	scanf("%d%d", &n, &m);
	while(n+m){
		memset(M,0,sizeof(M));
		
		for(i=0;i<m;++i){
			scanf("%d%d", &x, &y);
			//printf("%d %d\n", x, y);
			--x;--y;
			M[x][y]=M[y][x]=1;
		}
		
		memset(colour, 0, sizeof(colour));
		num = 0;
		no=1;
		dfs( 0, -1);
		
		if(no)printf("S\n");
		else printf("N\n");
		
		scanf("%d%d", &n, &m);
	}
	return 0;
}
